package com.game.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.util.Hashtable;
import java.util.Properties;

public class PropertiesFileReader {
	
	private static String dir_to_scan = "data";
	private static String extension = "properties";
	static Hashtable<String,String> hash = new Hashtable<String, String>();
	
	
	public static void loadProperties() {
		File f = new File(PropertiesFileReader.dir_to_scan);
		FilenameFilter filter = new FilenameFilter() {
			public boolean accept(File dir, String name) {
				return name.endsWith(".properties");
			}
		};
		
		String[] allPropertiesFiles = null;
		if (f.isDirectory()) {
			allPropertiesFiles = f.list(filter);	
		} else {
			allPropertiesFiles[0] = f.getName();
		}
		for (String propfile: allPropertiesFiles) {
			Properties prop = new Properties();
			try {
				prop.load(new FileInputStream(propfile));
			} catch (Exception E) {
				
			}
			for (String pnames: prop.stringPropertyNames()) {
				hash.put(pnames, prop.getProperty(pnames));					
			}				
		}				
	}
}
